-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Radar Chart Span Gaps #5359
Radar Chart Span Gaps #5359
Conversation
@simonbrunel I added tests and a section to the docs. I found bugs in the line element and the filler plugin when the first point in the line is skipped. This PR includes fixes for those as well |
src/controllers/controller.radar.js
Outdated
@@ -50,6 +51,7 @@ module.exports = function(Chart) { | |||
// Model | |||
_model: { | |||
// Appearance | |||
spanGaps: dataset.spanGaps ? dataset.spanGaps : me.chart.options.spanGaps, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataset.spanGaps !== undefined ? dataset.spanGaps : me.chart.options.spanGaps
, else it will ignore dataset.spanGaps: false
src/controllers/controller.radar.js
Outdated
|
||
for (i = 0, ilen = points.length; i < ilen; ++i) { | ||
point = points[i]; | ||
model = point._model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model = points[i]._model;
src/controllers/controller.radar.js
Outdated
@@ -50,6 +51,7 @@ module.exports = function(Chart) { | |||
// Model | |||
_model: { | |||
// Appearance | |||
spanGaps: dataset.spanGaps !== undefined ? dataset.spanGaps : me.chart.options.spanGaps, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do:
spanGaps: helpers.valueOrDefault(dataset.spanGaps, me.chart.options.spanGaps)
src/controllers/controller.radar.js
Outdated
helpers.each(points, function(point, index) { | ||
me.updateElement(point, index, reset); | ||
}, me); | ||
for (i = 0, ilen = points.length; i < ilen; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++i
is a little non-standard. The file has i++
everywhere else, which I see much more commonly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using ++i
in for loops but it's an habit that comes from C/C++ which is (was?) an optimization. I'm not sure it has any incidence in JavaScript though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v8 produces the same bytecode in either case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The habit for me came from my c++ days too. Will try and address the comments tomorrow
src/elements/element.line.js
Outdated
if (me._loop && points.length) { | ||
points.push(points[0]); | ||
for (index = 0; index < points.length; ++ index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an extra space in ++ index
(also I think index++
would be more consistent)
@etimberg don't forget there's a few comments on this PR |
@etimberg just a quick reminder about this PR |
@etimberg the CI is failing, can you have a look? |
@simonbrunel I fixed the linting error. Will try and investigate the test failures. They don't happen locally but I thought I'd gotten all the text off |
@etimberg one of the failing tests "Chart.elements.Line should be able to draw with a loop back to the beginning point when the first point is skipped" is here: https://github.com/chartjs/Chart.js/blob/master/test/specs/element.line.tests.js#L1876 With your changes there's an extra
Do you need to update Or is it a bug that there's an additional |
@etimberg the other test that's failing are the radar image tests below. I've included these screenshots to help demonstrate how exactly it's failing They seem to be caused by the change to:
If I change |
Thanks for the images @benmccann. Going to look into this now. |
Closing since this surprisingly hard to get right. The radar chart should skip null points but doing so breaks the filler plugin. |
Resolves #5358
To Do